<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>教学实验环境管理</title>
	<meta name="decorator" content="default"/>

	<script type="text/javascript">
		$(document).ready(function() {
			var increaseTimeAllow=${sceneEnvironment.increaseTimeAllow};
			if(increaseTimeAllow=='1')
				$("#addTimeDiv").hide();

		});
	</script>
	<script type="text/javascript">
		function timeAllowChoose(selete)
		{
			var option=selete.options[selete.selectedIndex].value;
			if(option==0)
			{
				$("#addTimeDiv").show();

			}else{
				$("#addTimeDiv").hide();

			}

		}
		function checkValidate()
		{
			var environmentName=document.getElementById("environmentName").value;

			var environmentTimeSelect=document.getElementById("environmentTime");
			var environmentTimeOption=environmentTimeSelect.options[environmentTimeSelect.selectedIndex].value;


            var environmentAccessModeSelect=document.getElementById("environmentAccessMode");
            var environmentAccessModeOption=environmentAccessModeSelect.options[environmentAccessModeSelect.selectedIndex].value;

			var increaseTimeAllowSelect=document.getElementById("increaseTimeAllow");
			var increaseTimeAllowOption=increaseTimeAllowSelect.options[increaseTimeAllowSelect.selectedIndex].value;

			var increaseTimeSelect=document.getElementById("increaseTime");
			var increaseTimeOption=increaseTimeSelect.options[increaseTimeSelect.selectedIndex].value;

			var increaseNumberSelect=document.getElementById("increaseNumber");
			var increaseNumberOption=increaseNumberSelect.options[increaseNumberSelect.selectedIndex].value;

			//判断是否为空
			if(environmentName==null||environmentName=="")
			{
				window.alertx("请输入教学实验环境名称！");
				return false;
			}
			if(environmentTimeOption==null||environmentTimeOption=="")
			{
				window.alertx("请选择实验时间！");
				return false;
			}
            if(environmentAccessModeOption==null||environmentAccessModeOption=="")
            {
                window.alertx("请选择实验设备访问方式！");
                return false;
            }
			if(increaseTimeAllowOption==0)
			{
				if(increaseTimeOption==null||increaseTimeOption=="")
				{
					window.alertx("请选择每次增加的时间！");
					return false;
				}
				if(increaseNumberOption==null||increaseNumberOption=="")
				{
					window.alertx("请选择增加的次数！");
					return false;
				}
			}else{

			}



		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/scene/sceneEnvironment/">教学实验环境列表</a></li>
		<li class="active"><a href="${ctx}/scene/sceneEnvironment/form?id=${sceneEnvironment.id}">教学实验环境<shiro:hasPermission name="scene:sceneEnvironment:edit">${not empty sceneEnvironment.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="scene:sceneEnvironment:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<jsp:useBean id="sceneEnvironment"  class="com.lczyfz.istep.modules.scene.entity.SceneEnvironment" scope="request" ></jsp:useBean>
	<form:form id="inputForm" modelAttribute="sceneEnvironment" action="${ctx}/scene/sceneEnvironment/topology" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">教学实验环境名称：</label>
			<div class="controls">
				<form:input id="environmentName" name="environmentName" path="environmentName" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">教学实验环境类型：</label>
			<div class="controls">
				<select id="environmentType" name="environmentType" class="input-xlarge required">


					<c:choose>
						<c:when test="${isSuperAdmin=='false'}">
							<option value="0" selected>${fns:getDictLabel("0",'scene_env_type',"无")}</option>
						</c:when>
						<c:otherwise>
							<c:forEach var="attribute" items="${fns:getDictList('scene_env_type')}">
								<option value="${fns:getDictValue(attribute,'scene_env_type',"")}" <c:if test="${fns:getDictValue(attribute,'scene_env_type','')==sceneEnvironment.environmentType}">selected</c:if>>${attribute}</option>
							</c:forEach>
						</c:otherwise>
					</c:choose>


				</select>

				<%--<form:select path="environmentType" class="input-xlarge required">--%>
					<%--<form:option value="" label=""/>--%>
					<%--<form:options items="${fns:getDictList('scene_env_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>--%>
				<%--</form:select>--%>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">实验时间：</label>
			<div class="controls">
				<select id="environmentTime" name="environmentTime" path="environmentTime" class="input-xlarge required">
					<c:forEach var="attribute" items="${fns:getDictList('scene_env_time')}">
						<option value="${fns:getDictValue(attribute,'scene_env_time',"")}" <c:choose><c:when test="${sceneEnvironment.environmentTime==null||sceneEnvironment.environmentTime==''}"><c:if test="${fns:getDictValue(attribute,'scene_env_time','')==3}">selected</c:if></c:when><c:otherwise><c:if test="${fns:getDictValue(attribute,'scene_env_time','')==sceneEnvironment.environmentTime}">selected</c:if></c:otherwise></c:choose>>${attribute}</option>
					</c:forEach>

				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">实验设备访问方式：</label>
			<div class="controls">

				<select id="environmentAccessMode" name="environmentAccessMode" path="environmentAccessMode" class="input-xlarge required">

					<c:forEach var="attribute" items="${fns:getDictList('scene_env_access_mode')}">
						<option value="${fns:getDictValue(attribute,'scene_env_access_mode',"")}"
								<c:if test="${fns:getDictValue(attribute,'scene_env_access_mode','')==sceneEnvironment.environmentAccessMode}">selected
								</c:if>
							>${attribute}</option>
					</c:forEach>

				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">标签：</label>
			<div class="controls">
				<form:input path="label" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<%--<div class="control-group">--%>


			<%--&lt;%&ndash;<label class="control-label">是否允许增加实验时间：</label>&ndash;%&gt;--%>
			<%--&lt;%&ndash;<div class="controls">&ndash;%&gt;--%>
				<%--&lt;%&ndash;<form:radiobuttons path="increaseTimeAllow" items="${fns:getDictList('scene_env_increase_time_allow')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>&ndash;%&gt;--%>
			<%--&lt;%&ndash;</div>&ndash;%&gt;--%>
		<%--</div>--%>
		<div class="control-group">
			<label class="control-label">是否允许增加实验时间:</label>

			<div class="controls">
				<select id="increaseTimeAllow" name="increaseTimeAllow" onchange="timeAllowChoose(this)">

					<option value="1" <c:if test="${sceneEnvironment.increaseTimeAllow=='1'}">selected</c:if>>否</option>
					<option value="0" <c:if test="${sceneEnvironment.increaseTimeAllow=='0'}">selected</c:if>>是</option>
				</select>
			</div>
		</div>
		<div id="addTimeDiv" hidden>


		<div class="control-group">
			<label class="control-label">每次增加时间：</label>
			<div class="controls">
				<form:select path="increaseTime" class="input-xlarge ">
					<form:option value="" label="">===请选择===</form:option>
					<form:options items="${fns:getDictList('scene_env_increase_time')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">增加次数：</label>
			<div class="controls">
				<form:select path="increaseNumber" class="input-xlarge ">
					<form:option value="" label="">===请选择===</form:option>
					<form:options items="${fns:getDictList('scene_env_increase_number')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<%--<shiro:hasPermission name="scene:sceneEnvironment:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="下一步" onclick="window.location.href='${ctx}/scene/sceneEnvironment/topology'"/>&nbsp;</shiro:hasPermission>--%>
			<shiro:hasPermission name="scene:sceneEnvironment:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="下一步" onclick=" return checkValidate()"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>